package com.youku.baseUI
{
   import flash.display.Sprite;
   import flash.display.Shape;
   import flash.text.TextField;
   import com.youku.utils.AssetUtil;
   import flash.text.TextFormat;
   import com.youku.skin.YaheiFontManager;
   import flash.text.TextFieldAutoSize;
   
   public class ButtonInfo extends Sprite
   {
      
      public function ButtonInfo() {
         super();
         this.init();
      }
      
      protected var _background:Shape;
      
      protected var _hintTextField:TextField;
      
      protected var _textTotalWidth:uint = 250;
      
      protected var _textHeight:uint = 25;
      
      protected var _container:Sprite;
      
      private var _arrowWidth:Number = 5;
      
      private var _arrowHeight:Number = 5;
      
      private function init() : void {
         this._background = new Shape();
         this._hintTextField = AssetUtil.getTextField(false);
         this._hintTextField.defaultTextFormat = new TextFormat(YaheiFontManager.MICROSOFT_YAHEI,14,12961221);
         this._hintTextField.autoSize = TextFieldAutoSize.CENTER;
         this._hintTextField.width = this._textTotalWidth;
         this._hintTextField.height = this._textHeight;
         this._hintTextField.selectable = false;
         this._container = new Sprite();
         addChild(this._container);
         this._container.addChild(this._background);
         this._container.addChild(this._hintTextField);
      }
      
      public function setData(param1:String, param2:uint, param3:int) : void {
         if(param1.length > 20)
         {
            this._hintTextField.text = param1.slice(0,20);
         }
         else
         {
            this._hintTextField.text = param1;
         }
         if(this._hintTextField.textWidth > 250)
         {
            this._textTotalWidth = 250;
         }
         else if(this._hintTextField.textWidth < 50)
         {
            this._textTotalWidth = 50;
         }
         else
         {
            this._textTotalWidth = this._hintTextField.textWidth;
         }
         
         var _loc4_:Number = 0;
         var _loc5_:Number = (this._textTotalWidth + 8) / 2;
         if(_loc5_ > param2 - param3)
         {
            _loc4_ = -(_loc5_ - (param2 - param3)) - 5;
         }
         if(_loc5_ > param3)
         {
            _loc4_ = _loc5_ - param3 + 5;
         }
         var _loc6_:Number = -_loc5_ + _loc4_;
         this._background.graphics.clear();
         this._background.graphics.beginFill(1907997,0.85);
         this._background.graphics.lineTo(0,0);
         this._background.graphics.lineTo(-this._arrowWidth,-this._arrowHeight);
         this._background.graphics.lineTo(_loc6_,-this._arrowHeight);
         this._background.graphics.lineTo(_loc6_,-this._textHeight - this._arrowHeight);
         this._background.graphics.lineTo(_loc5_ * 2 + _loc6_,-this._textHeight - this._arrowHeight);
         this._background.graphics.lineTo(_loc5_ * 2 + _loc6_,-this._arrowHeight);
         this._background.graphics.lineTo(this._arrowWidth,-this._arrowHeight);
         this._background.graphics.lineTo(0,0);
         this._background.graphics.endFill();
         this._hintTextField.x = _loc6_ + (this._textTotalWidth - this._hintTextField.textWidth) / 2 + 2;
         this._hintTextField.y = -this._arrowHeight - this._textHeight + 1;
      }
   }
}
